#include "head.h"
int yes=0;
int select_user_db(users * a,int b,char **c,char **d){
    for (int i = 0; i < b-1; ++i) {
        if(strcmp(c[i],a->account)==0&& strcmp(c[i+1],a->password)==0){
            yes=1;
            return 1;
        }
    }
    return 0;
}
int select_db(users *b){
    char * a="select account,password from user ;";
     sqlite3_exec(db,a,select_user_db,b,NULL);
    if(yes!=1){
        //重置
        yes=0;
        return -1;
    } else{
        yes=0;
        return 1;
    }
}
int insert_db(users a){
    char sql[250];
    sprintf(sql,"insert into user(account,password) values('%s','%s');",a.account,a.password);
    int ls =sqlite3_exec(db,sql,NULL,NULL,NULL);
    if(ls!=SQLITE_OK){
        return -1;
    }
    printf("注册成功\n");
    return 0;
};